package study;

public class InstanceofDemo {
    public static void main(String[] args) {
        AA[] aas = {new BB(), new CC(), new CC(), new BB()};
        for (AA aa : aas) {
            aa.show();
            if (aa instanceof BB) {
                BB bb = (BB)aa;
                bb.showBB();
            }
            else if (aa instanceof CC) {
                CC cc = (CC)aa;
                cc.showCC();
            }
        }
    }
}

interface AA{
    void show();
}

class BB implements AA {
    @Override
    public void show(){
        System.out.println("bbbb");
    }
    public void showBB() {
        System.out.println("BBBB");
    }
}

class CC implements AA {
    int c = 3;
    @Override
    public void show() {
        System.out.println("cccc  " + c);
    }
    public void showCC() {
        System.out.println("CCCC");
    }
}
